﻿<?php

/**
 * @author Nguyen Xuan Hong
 * @copyright 2010
 */
@ini_set("memory_limit","20M");
@ob_start();

#@ Error reporting config

error_reporting(E_ALL & ~E_NOTICE & ~E_WARNING);



@header("Content-Type: text/html; charset=UTF-8");

if (!session_id()) @session_start();


if (!ini_get('register_globals')) {
	@$_GET = $HTTP_GET_VARS;
	@$_POST = $HTTP_POST_VARS;
	@$_COOKIE = $HTTP_COOKIE_VARS;
	extract($_GET);
	extract($_POST);
}

if (!$_SERVER['HTTP_USER_AGENT'] || !$_SERVER["REQUEST_URI"]) exit();


	$dbc_localmode	= TRUE;
	$dbc_autofind	= TRUE;

	$dbconfig['host'] = "localhost";
	$dbconfig['user'] = "ngoinhatt_user";
	$dbconfig['pass'] = "kidshome";
	$dbconfig['dbas'] = "ngoinhatt_db";
	
	include('dfunction.php');
	include('mysql.class.php');
	include('db.tbl.php');
	
	$mysql = new clsMySQL;
	if(!$mysql->connect($dbconfig['host'], $dbconfig['user'], $dbconfig['pass'], $dbconfig['dbas']))
	{
		$mysql->puterror();
		exit();
	}
	
	function redirect($location, $relay=0)
	{
			// Redirect for IIS
		exit("<html><head><meta http-equiv=\"refresh\" content=\"".$relay."; url=". $location . "\"></head><body></body></html>");
	}
	
	function delete_file($old_file)
	{
		$old_path = "../".$old_file;
		if(is_file($old_path))
			unlink($old_path);
	}
	
	function upload_file($updir, $input, $old_file, $id='')
	{
		$file_name = $_FILES[$input]['name'];
		if($file_name != "")
		{
			$old_path = "../".$old_file;
			if(is_file($old_path))
				unlink($old_path);
			if($id)
			{
				$new_file = $updir.$id.'_'.$file_name;
				$new_path = "../".$updir.$id.'_'.$file_name;
			}
			else
			{
				$new_file = $updir.$file_name;
				$new_path = "../".$updir.$file_name;
			}
			move_uploaded_file($_FILES[$input]['tmp_name'],$new_path);
			return $new_file;
		}
		return "";
	}
?>